-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update middleware.mdx #10810
base: main
Are you sure you want to change the base?
Update middleware.mdx #10810
Conversation
Updated the env.d.ts section to reflect the current working implementation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
Hello! Thank you for opening your first PR to Astro’s Docs! 🎉 Here’s what will happen next:
|
declare global { | ||
namespace App { | ||
interface Locals { | ||
user: { | ||
name: string | ||
}, | ||
welcomeTitle: () => string, | ||
orders: Map<string, object> | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ruohki and thanks for taking the time to help making the docs better!
I don't know if you followed the discussion in Discord but I don't think we should use declare global
here because without imports it is working as expected. But I agree, we should show how to use an imported type as it seems to be confusing. Perhaps something like:
declare global { | |
namespace App { | |
interface Locals { | |
user: { | |
name: string | |
}, | |
welcomeTitle: () => string, | |
orders: Map<string, object> | |
} | |
} | |
} | |
namespace App { | |
interface Locals { | |
site: { | |
title: string | |
}, | |
welcomeTitle: () => string, | |
orders: Map<string, object>, | |
user: import("@supabase/supabase-js").User | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm so maybe we could show both versions and mention that if someone is using imports to use the global approach? Or yeah at least clarify on how to use imported types. I do this regularly, sort of misuse locals as my little singleton accesor
Edit: made change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that looks better since I think the example should remain an ambient module declaration!
Regarding the format (as a commented property or not, or if we need to mention that it is Typescript behavior), I'm not sure what is best so I'll let Sarah (or someone else) give their opinion since it's kind of new content. She'll probably be able to give better advice! 😄 I will post a comment with a bit more context for reviewers.
PR's context: This issue was raised again yesterday, so (after ruohki's PR) the idea was to provide an example on how to do imports in a I think adding a property could be enough to show that, but is it clear enough? I know we avoid documenting the behavior of third-party technologies, but should we add more context here? |
A comment from maintainer's discussion:
|
Description (required)
Updated the env.d.ts section to reflect the current working implementation
discord: ruohki